package com.bicon.life.core.base.repository.jpa;

import com.bicon.life.core.domain.entity.BaseEntity;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Lock;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.data.repository.query.QueryByExampleExecutor;

import javax.persistence.LockModeType;
import java.io.Serializable;

/**
 * Created by zhoubin on 2016/1/4.
 */
public interface BaseDao<T extends BaseEntity, ID extends Serializable> extends PagingAndSortingRepository<T, ID>,JpaSpecificationExecutor<T>,QueryByExampleExecutor<T> {

    /**
     * 行级锁
     * @param id
     * @return
     */
    @Lock(value = LockModeType.PESSIMISTIC_WRITE)
    public T findById(ID id);
}
